package com.ricky.core.net.msg;

import com.ricky.core.net.ByteBuffer;

public class ByteContext extends Context<ByteBuffer> {

	public ByteContext(int type,ByteBuffer buffer)
	{
		super.setType(type);
		super.setContent(buffer);
	}
	
	public ByteContext(int type)
	{
		super.setType(type);
	}

	@Override
	public byte[] getBytes() {
		if(getContent()!=null)			
			return this.getContent().getBytes();
		else
			return new byte[0];
	}

	@Override
	public void decode(byte[] in) {
		ByteBuffer buffers = new ByteBuffer();
		buffers.writeBytes(in,0,in.length);//读取内容
		this.setContent(buffers);
	}

}
